unit dbUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, DBCtrls, Grids, DBGrids, DB, DBClient, ComCtrls, MidasLib,
  Menus;

const
  DbFileName= 'lich.cds';

type
  TdbForm = class(TForm)
    StatusBar1: TStatusBar;
    DataSource1: TDataSource;
    CDS: TClientDataSet;
    DBGrid1: TDBGrid;
    DBNavigator1: TDBNavigator;
    MainMenu1: TMainMenu;
    mAddtestrecord: TMenuItem;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure mAddtestrecordClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    Procedure Add(SData:array of AnsiString; NData: Array of double);
  end;

var
  dbForm: TdbForm;

implementation

{$R *.dfm}

procedure TdbForm.FormCreate(Sender: TObject);
begin
  CDS.Close;
  CDS.FileName:= ExtractFilePath(Application.Exename) + DbFilename;
  CDS.Open;
end; {proc}


procedure TdbForm.FormDestroy(Sender: TObject);
begin
  CDS.Close; // .Cancel;
end; {proc}


procedure TdbForm.mAddtestrecordClick(Sender: TObject);
Var
  s:array[0..3] of AnsiString;
  n:array[0..6] of double;
begin
  s[0]:= 'U1234567';
  s[1]:= 'SAMGAS';
  s[2]:= 'RS2001L/A';
  s[3]:= 'G4';
  n[0]:=  9.93;
  n[1]:= -0.98;
  n[2]:=  1.18;
  n[3]:=  2.45;
  n[4]:=  0.039;
  n[5]:= -3.4;
  n[6]:= 44567.3489;
  Add(s,n);
end; {proc}


Procedure TdbForm.Add(SData:array of AnsiString; NData: Array of double);
begin
  CDS.AppendRecord([SData[0],SData[1],SData[2],SData[3],NData[0],NData[1],NData[2],NData[3],NData[4],NData[5],NData[6]]);
  CDS.MergeChangeLog;
  CDS.SaveToFile(CDS.FileName, dfbinary);
end; {proc}



end.
